var t = getApp();

Page({
    data: {
        storeName: {
            thumb: "",
            name: ""
        },
        payMuch: "0"
    },
    onLoad: function(t) {},
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    _handleKeyPress: function(t) {
        var e = t.currentTarget.dataset.num;
        if (-1 == e) return !1;
        switch (String(e)) {
          case ".":
            this._handleDecimalPoint();
            break;

          case "D":
            this._handleDeleteKey();
            break;

          case "S":
            this._handleConfirmKey();
            break;

          default:
            this._handleNumberKey(e);
        }
    },
    _handleDecimalPoint: function() {
        if (this.data.payMuch.indexOf(".") > -1) return !1;
        this.data.payMuch.length ? this.setData({
            payMuch: this.data.payMuch + "."
        }) : this.setData({
            payMuch: "0."
        });
    },
    _handleDeleteKey: function() {
        var t = this.data.payMuch;
        t.length <= 1 ? this.setData({
            payMuch: "0"
        }) : this.setData({
            payMuch: t.substring(0, t.length - 1)
        });
    },
    _handleConfirmKey: function() {
        var t = this.data.payMuch;
        if (!t.length || 0 === Number(t)) return wx.showToast({
            icon: "none",
            title: "您目前未输入!",
            duration: 1500
        }), !1;
        t.indexOf(".") > -1 && t.indexOf(".") === t.length - 1 && (t = Number(t.substring(0, t.length - 1)).toFixed(2)), 
        t = Number(t).toFixed(2), this.setData({
            payMuch: t
        }), this.confirmOrder();
    },
    confirmOrder: function() {
        var t = this.data.payMuch;
        t && t > 0 ? (this.getData(!0, t), setTimeout(function() {
            wx.hideLoading();
        }, 3e3)) : wx.showToast({
            icon: "none",
            title: "请输入正确的付款金额!",
            duration: 1500
        });
    },
    _handleNumberKey: function(t) {
        var e = this.data.payMuch;
        if (e.indexOf(".") > -1 && e.substring(e.indexOf(".") + 1).length < 2 && this.setData({
            payMuch: e + t
        }), !(e.indexOf(".") > -1)) if (0 == t && 0 == e.length) this.setData({
            payMuch: "0."
        }); else {
            if (e.length && 0 === Number(e.charAt(0))) return void this.setData({
                payMuch: t
            });
            this.setData({
                payMuch: e + t
            });
        }
    },
    getData: function(e, n) {
        var a = {
            bolshow: e,
            money: n,
            moneyBol: !0
        }, i = "";
        wx.showLoading({
            title: "正在发起付款金额"
        });
        try {
            var o = wx.getStorageSync("wx_token");
            o && (i = o);
        } catch (t) {
            console.log(t);
        }
        wx.request({
            url: t.getFrogproNetAddresss("plugin.store-cashier.frontend.app.cashier.statistic.index"),
            header: {
                "Content-Type": "application/json",
                Accept: "application/json",
                Cookie: "PHPSESSID=" + i
            },
            method: "get",
            success: function(e) {
                var i = e.data;
                1 == i.result ? (wxfaceapp.postMsg({
                    targetAppid: t.data.accept_message_id,
                    content: JSON.stringify(a),
                    success: function(t) {},
                    fail: function(t) {
                        wx.showToast({
                            title: t.reply,
                            icon: "none",
                            duration: 2e3
                        });
                    }
                }), wx.redirectTo({
                    url: "/packageC/frogpro/waitingPayment/waitingPayment?money=" + n
                })) : 0 == i.result && "请登录" === i.msg ? wx.redirectTo({
                    url: "/packageC/frogpro/backScreenlogin/backScreenlogin"
                }) : wx.showToast({
                    title: i.msg,
                    icon: "none",
                    duration: 1500
                }), wx.hideLoading();
            },
            fail: function(t) {
                wx.hideLoading(), wx.showToast({
                    title: t,
                    icon: "none",
                    duration: 1500
                });
            }
        });
    }
});